{include file="Public:header" /}
<style>
	.pagination a{
		background-color: #f4f4f4;
		z-index: 2;
		border:1px solid #000;
		border-color: rgb(221, 221, 221);
		padding: 4px 10px;
		margin:0px 3px;
		border-radius:10%;
	}
	.form-control{
		font-size: 12px;
	}
</style>


<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
	<div class="row">
		<div class="col-sm-12">
			<div class="ibox float-e-margins">
				<div class="ibox-title">
					<h5>中奖用户列表</h5>
					<div class="ibox-tools">
						<!--<a href="{:U('Partuser/partUserList')}" class="btn btn-primary">刷新</a>-->
					</div>
				</div>
				<div class="ibox-content">
					<div class="row" style="position: relative;margin-right: 100px;">
						<div class="col-sm-3">
							<!--<a href="#" class="btn btn-primary">
								<span class="fa fa-plus"></span>
								添加奖品
							</a>-->
						</div>
						<form class="form-inline" action="__URL__/PrizeList" method="get">
							<div class="col-sm-9" style="position: relative;left:-3%;">
								<div class="input-group col-sm-4  pull-right">
									<!--<input type="text" name="mobile" value="<?php echo I('mobile'); ?>" placeholder="请输入用户电话" class="input-sm form-control">-->
									<input type="text" name="user_name" value="<?php echo I('user_name'); ?>" placeholder="请输入用户名称" class="input-sm form-control">

									<span class="input-group-btn">
										<button type="submit" class="btn btn-sm btn-primary">搜索</button>
									</span>
								</div>
								<!--<div class="input-group pull-right" style="border: 1px solid #e5e6e7;width: 100px;height:30px;">
									<select style="height: 30px;border:none;" name="prize_type">
										<option value="0">请选择奖品类型</option>
										<option {if condition="I('prize_type') eq 2"} selected {/if} value="2">实物</option>
										<option {if condition="I('prize_type') eq 1"} selected {/if} value="1">抵用券</option>
									</select>
								</div>-->

								<div class="input-group pull-right"  style="border: 1px solid #e5e6e7;width: 110px;height:30px;">
									<input class="input-sm form-control" id="endtime" style="border: none;"  type="text" name="endtime" value="<?php echo I('get.endtime'); ?>" placeholder="请输入结束时间">
								</div>
								<div class="input-group pull-right"  style="border: 1px solid #e5e6e7;width: 110px;height:30px;">
									<input class="input-sm form-control" id="starttime" style="border: none;"  type="text" name="starttime" value="<?php echo I('get.starttime'); ?>" placeholder="请输入起始时间" >
								</div>
							</div>
						</form>
						<div style="text-align: center;width: 70px;height:30px;float: right;position: absolute;right: -20px;background-color: #1ab394;">
								<span class="input-group-btn">
									<!--href="__URL__/export"-->
									<a href="__URL__/export"  style="width: 65px;height: 30px;" class="btn btn-sm btn-primary">导出搜索</a>
								</span>
						</div>
						<div style="text-align: center;width: 70px;height:30px;float: right;position: absolute;right: -100px;background-color: #1ab394;">
								<span class="input-group-btn">
									<!--href="__URL__/export"-->
									<a href="__URL__/allExport"  style="width: 65px;height: 30px;" class="btn btn-sm btn-primary">导出全部</a>
								</span>
						</div>
					</div>

					<br />
					<div class="table-responsive">
						<form action="__URL__/deleteAllPriRe" method="post">
							<table class="table table-bordered table-hover"
								   id="categoryTable">
								<thead>
								<tr style="background: #f9f9f9;">
									<th><input type="checkbox" onclick="all_check()"></th>
									<th height="40">用户ID</th>
									<th>姓名</th>
									<!--<th>电话</th>-->
									<!--<th>活动名称</th>-->
									<th>奖品名称</th>
									<!--<th>奖品类型</th>-->
									<th>中奖时间</th>
									<th width="100">操作</th>
								</tr>
								</thead>
								<tbody>
								{foreach name="user" item="vo"}
								<tr>
									<td><input type="checkbox" name="id[]" value="{$vo['record_id']}"></td>
									<td>{$vo['user_id']}</td>
									<td>{$vo['user_name']}</td>
									<!--<td>{$vo['mobile']}</td>-->
									<!--<td>{$vo['activity_name']}</td>-->
									<td>{$vo['prize_name']}</td>
									<!--<td>{if condition="$vo['prize_type'] eq 2"}实物{else/}抵用券{/if}</td>-->
									<td>{$vo['time']|date="Y-m-d H:i:s",###}</td>
									<td class="center">
										<div class="dropdown">
											<button class="btn btn-primary dropdown-toggle"
													type="button" id="dropdownMenu1" data-toggle="dropdown"
													aria-haspopup="true" aria-expanded="true">
												操作
												<span class="caret"></span>
											</button>
											<ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
												<li>
													<a role="button" class="btn btn-danger"
													   style="margin-bottom: 0px;"
													   onclick="deletePrize(this,{$vo['record_id']})" href="#">
														<span class="fa fa-trash-o"></span>
														删除
													</a>
												</li>
											</ul>
										</div>
									</td>
								</tr>
								{/foreach}
								</tbody>
							</table>
							<div style="padding-left:0px;" class="col-sm-3 text-left">
								<button tpye="submit" class="btn btn-danger">删除</button>
							</div>
						</form>
						<div class="col-sm-12 text-center">
							<nav aria-label="Page navigation">
								<ul class="pagination">
									{$page}
								</ul>
							</nav>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>



<script>
    var status = 0;
    function all_check()
    {
        if (status==0)
        {
            $("input[name='id[]']").each(function () {
                $(this).prop("checked",true);
                status=1;
            });
        }
        else if (status==1)
        {
            $("input[name='id[]']").each(function () {
                $(this).prop("checked",false);
                status=0;
            });
        }
    }
</script>
<!-- Modal -->

<!-- Modal -->

{include file="Public:footer" /}

<script type="text/javascript" src="__PUBLIC__/Admin/bootstrap-datetimepicker-master/js/bootstrap-datetimepicker.js" charset="UTF-8"></script>
<script type="text/javascript" src="__PUBLIC__/Admin/bootstrap-datetimepicker-master/js/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
<script type="text/javascript">
    $('#starttime').datetimepicker({
        language:  'zh-CN',
        format: 'yyyy-mm-dd',
        minView:'month',
        autoclose:true//日期选择完成后是否关闭选择框
    });
    $('#endtime').datetimepicker({
        language:  'zh-CN',
        minView:'month',
        format: 'yyyy-mm-dd',
        autoclose:true //Important! See issue #1075
    });
</script>

<script>
    function  exportExcel() {
		var mobile = $("input[name='mobile']").val();
        var starttime = $("input[name='starttime']").val();
        var endtime = $("input[name='endtime']").val();
        var prize_type = $("select[name='prize_type']").val();

        $.ajax({
            url : '__URL__/export',
            data : {'mobile':mobile,'starttime':starttime},
            type : 'get',
            dataType : 'json',
            async : false,   //取消同步，执行完之后再往下执行
            success : function(data){
                if(data.status == 1){
                    layer.msg('成功');
                }
            }
        });
    }

</script>




<script>
    $(document).ready(function() {
        /**
         * 下面是进行插件初始化
         * 你只需传入相应的键值对
         * */
        $('#defaultForm').bootstrapValidator({
            message: 'This value is not valid',
            feedbackIcons: {/*输入框不同状态，显示图片的样式*/
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
            fields: {/*验证*/
                shop_name: {/*键名username和input name值对应*/
                    message: '商品名称验证失败',
                    validators: {
                        notEmpty: {/*非空提示*/
                            message: '商品名称不能为空'
                        },
                        stringLength: {/*长度提示*/
                            min: 2,
                            max: 30,
                            message: '商品名称长度必须在2到30之间'
                        }/*最后一个没有逗号*/
                    }
                },
                shop_address: {/*键名username和input name值对应*/
                    message: '商品地址验证失败',
                    validators: {
                        notEmpty: {/*非空提示*/
                            message: '商品地址不能为空'
                        },
                        stringLength: {/*长度提示*/
                            min: 2,
                            max: 30,
                            message: '商品地址长度必须在2到30之间'
                        }/*最后一个没有逗号*/
                    }
                },
                shop_tel: {/*键名username和input name值对应*/
                    message: '商品电话验证失败',
                    validators: {
                        notEmpty: {/*非空提示*/
                            message: '商品电话不能为空'
                        },
                        stringLength: {/*长度提示*/
                            min: 2,
                            max: 30,
                            message: '商品电话长度必须在2到30之间'
                        }/*最后一个没有逗号*/
                    }
                },
                shop_description: {/*键名username和input name值对应*/
                    message: '商品描述验证失败',
                    validators: {
                        notEmpty: {/*非空提示*/
                            message: '商品描述不能为空'
                        },
                        stringLength: {/*长度提示*/
                            min: 2,
                            max: 30,
                            message: '商品描述长度必须在2到30之间'
                        }/*最后一个没有逗号*/
                    }
                },
                shop_coord:{/*键名username和input name值对应*/
                    message: '商品坐标验证失败',
                    validators: {
                        notEmpty: {/*非空提示*/
                            message: '商品坐标不能为空'
                        },
                        stringLength: {/*长度提示*/
                            min: 2,
                            max: 30,
                            message: '商品坐标长度必须在2到30之间'
                        }/*最后一个没有逗号*/
                    }
                },
                metro_address:{/*键名username和input name值对应*/
                    message: '地铁地址验证失败',
                    validators: {
                        notEmpty: {/*非空提示*/
                            message: '地铁地址不能为空'
                        },
                        stringLength: {/*长度提示*/
                            min: 2,
                            max: 30,
                            message: '地铁地址长度必须在2到30之间'
                        }/*最后一个没有逗号*/
                    }
                }

            }
            // 还有一个比较常用的就是submitHandler属性，它对应着提交按钮的事件方法。
            // submitHandler: function (validator, form, submitButton) {
            //alert("submit");
			/*  var menu_name = $("input[name='menu_name']").val();
			 var link = $("input[name='link']").val();
			 var ico = $("input[name='ico']").val();
			 $.ajax({
			 url : '__URL__/addMenu',
			 type : 'get',
			 data : {'menu_name' : menu_name, 'link' : link, 'ico':ico},
			 dataType : 'json',
			 success : function(data){
			 alert(data.message);
			 }
			 }); */
            // }
        });
    });

    //修改菜单
    function editGroup(obj){
        var group_id = $(obj).attr('group_id');
        var group_title = $(obj).attr('group_title');
        $('#myModal').modal('show');
        $("#defaultForm").attr('action','__URL__/editUserGroup?id='+group_id);
        $("input[name='title']").val(group_title);
    }

    // window.onload=setTotal();

    //删除
    function deletePrize(obj,p_id){
        layer.confirm('确定要删除数据吗',{btn:['确认','取消'], icon:3, closeBtn: 2 },function(index){
            $.ajax({
                url : '__URL__/prizeDel',
                data : {'record_id':p_id},
                type : 'get',
                dataType : 'json',
                async : false,   //取消同步，执行完之后再往下执行
                success : function(data){
                    if(data.status == 1){
                        layer.msg(''+data.message+'',{icon:2,time:1000});
                        $(obj).parent('li').parent('ul').parent('div').parent('td').parent('tr').remove();
                    }else if(data.status == 2){
                        layer.msg(''+data.message+'',{icon:1,time:1000});
                    }
                }
            });
        });
    }
</script>

</body>
</html>
